<template>
    <div id="Bill">
        <v-detail :detailData="inputData" :inputConfig="inputConfig" :rules="rules" @pop="setdata"
                  ref="detail"></v-detail>
    </div>
</template>

<script>
    import detail from "commons/Detail";
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "Bill",
        mixins: [baseMixin],
        props: {
            inputData: {
                type: Object
            }
        },
        data() {
            return {
                addflag: false,
                rules: {},
            }
        },
        computed: {
            inputConfig() {
                return [
                    [
                        {
                            type: "input",
                            label: this.$t('config.company'),
                            props: "arcorp",
                            tableConfig: [
                                {
                                    label: this.$t("bill.corpCode"),
                                    prop: "corp_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t("bill.corpName"),
                                    prop: "corp_name",
                                    input: "input",
                                },
                            ],
                            url: `/querySeachButton/billadmin.bic_corporation/1=1/adddate/?/${this.$store.state.wms}`,
                            disabled: this.addflag
                        },
                        {
                            type: "input",
                            label: this.$t("config.depart"),
                            props: "ardept",
                            tableConfig: [
                                {
                                    label: this.$t("config.departCode"),
                                    prop: "dept_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t("config.departName"),
                                    prop: "dept_name",
                                    input: "input",
                                },
                                {
                                    label: this.$t("bill.corpCode"),
                                    prop: "corp_code",
                                    input: "input",
                                },
                            ],
                            url: `/querySeachButton/billadmin.bic_department/1=1/adddate/?/${this.$store.state.wms}`,
                            disabled: this.addflag
                        },
                        {
                            type: "input",
                            label: this.$t("config.account"),
                            props: "aracct",
                            tableConfig: [
                                {
                                    label: this.$t("config.accountCode"),
                                    prop: "acct_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t("config.accountDesc"),
                                    prop: "acct_desc",
                                    input: "input",
                                },
                                {
                                    label: this.$t("config.departCode"),
                                    prop: "dept_code",
                                    input: "input",
                                },
                                {
                                    label: this.$t("bill.corpCode"),
                                    prop: "corp_code",
                                    input: "input",
                                },
                            ],
                            url: `/querySeachButton/billadmin.bic_account/1=1/adddate/?/${this.$store.state.wms}`,
                            disabled: this.addflag
                        }
                    ]
                ]
            }
        },
        methods: {
            setdata(data, id, close, listid) {
                if (id == "0") {
                    this.inputData.arcorp = data.corp_code;
                } else if (id == "1") {
                    this.inputData.ardept = data.dept_code;
                } else if (id == "2") {
                    this.inputData.aracct = data.acct_code;
                }

            }
        },
        mounted() {
            if (this.$store.state.wms.toUpperCase().includes('WMWHSE')) {
                this.addflag = true;
            }
        },
        components: {
            "v-detail": detail
        }
    }
</script>

<style scoped>

</style>
